package interviewpreparationkit.array

/**
 * [Arrays: Left Rotation](https://www.hackerrank.com/challenges/ctci-array-left-rotation)
 */
// Complete the rotLeft function below.
fun rotLeft(a: Array<Int>, d: Int): Array<Int> {
    val result = arrayOf(*a)
    val size = a.size
    val mod = d % size
    var t: Int
    for (i in 0 until size) {
        t = (i + mod) % size
        result[i] = a[t]
    }
    return result
}